//
//  MNDCreditListCell.m
//  minidai
//
//  Created by Vitas on 2018/8/3.
//  Copyright © 2018年 迷你贷. All rights reserved.
//

#import "MNDCreditListCell.h"

@implementation MNDCreditListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
    // Initialization code
}

#pragma mark -搭建界面

- (void)setupUI {
    ZZCircleProgress *progressView = [[ZZCircleProgress alloc]initWithFrame:CGRectMake(0, 0, 50, 50) pathBackColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1.0] pathFillColor:[UIColor colorWithRed:78/255.0 green:140/255.0 blue:238/255.0 alpha:1.0] startAngle:0 strokeWidth:1];
    progressView.startAngle = -90;
    progressView.showPoint = NO;
    progressView.animationModel = CircleIncreaseSameTime;
    //    progressView.progress = 0.6;
    [self.progressView addSubview:progressView];
    self.circleView = progressView;
    self.goInvestBtn.layer.cornerRadius = self.goInvestBtn.bounds.size.height*0.5;
    self.goInvestBtn.clipsToBounds = YES;
    
    self.creditorBtn.layer.cornerRadius = 3;
    
    self.discountButton.layer.cornerRadius = self.discountButton.frame.size.height*0.5;
    
}

- (void)setCreditorsModel:(MNDCreditorsModel *)creditorsModel {
    _creditorsModel = creditorsModel;
    [self configContents];
}

- (void)configContents{
    self.titleLabel.text = self.creditorsModel.title;
    self.moneyLabel.text = [NSString stringWithFormat:@"剩余%@元", self.creditorsModel.remainingable_tender ];
    self.yearAprLabel.text = self.creditorsModel.year_apr;
    self.circleView.progress = self.creditorsModel.nowProgress * 0.01;
    self.deadlineLabel.text = self.creditorsModel.deadline;
    //    self.statusLabel.text = self.creditorsModel.txt_status;
    if ([self.creditorsModel.txt_status isEqualToString:@"已撤销"]) {
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"creditor_cancel"];
        [self setGrayColorForView];
        [self.creditorBtn setBackgroundColor:kColorGray];
        self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.creditorsModel.principal];
    }else if([self.creditorsModel.txt_status isEqualToString:@"转让中"] || [self.creditorsModel.txt_status isEqualToString:@"进行中"]){
        self.statusImgV.hidden = YES;
        [self setBlackColorForView];
        [self.creditorBtn setBackgroundColor:kColorBlue];
    }else {//已完成
        [self setGrayColorForView];
        self.statusImgV.hidden = NO;
        self.statusImgV.image = [UIImage imageNamed:@"criditor_finish"];
        [self.creditorBtn setBackgroundColor:kColorGray];
        self.moneyLabel.text = [NSString stringWithFormat:@"项目总额%@元", self.creditorsModel.principal];
    }
    
    //显示债转标识
    self.creditorBtn.hidden = NO;
    [self.discountButton setTitle:[NSString stringWithFormat:@" %@%%折扣 ",self.creditorsModel.discount_apr] forState:UIControlStateNormal];
    [self.beginTimeLabel setHidden:YES];
    [self.beginLabel setHidden:YES];
    
}

- (void)setBlackColorForView {
    self.titleLabel.textColor = kColorBlack;
    self.yearAprLabel.textColor = kColorOrange;
    //        self.circleView
    self.deadlineLabel.textColor = kColorBlack;
    self.monthDescLabel.textColor = kColorBlack;
    self.precentLabel.textColor = kColorOrange;
}
- (void)setGrayColorForView {
    self.titleLabel.textColor = kColorGray;
    self.yearAprLabel.textColor = kColorGray;
    //        self.circleView
    self.deadlineLabel.textColor = kColorGray;
    self.monthDescLabel.textColor = kColorGray;
    self.precentLabel.textColor = kColorGray;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
